package com.jd.learn.mapper;

import com.jd.learn.entity.User;
import org.apache.ibatis.annotations.*;

import java.util.List;

public interface UserMapper {

    @Select("SELECT * FROM s_user_info")
    @Results({
            @Result(property = "username", column = "username"),
            @Result(property = "email",  column = "email"),
            @Result(property = "mobile",  column = "mobile"),
    })
    List<User> getAll();

    @Select("SELECT * FROM s_user_info WHERE id = #{id}")
    @Results({
            @Result(property = "username", column = "username"),
            @Result(property = "email",  column = "email"),
            @Result(property = "mobile",  column = "mobile"),
    })
    User getOne(Long id);

    @Insert("INSERT INTO s_user_info(username,email,mobile) VALUES(#{username}, #{email}, #{mobile})")
    void insert(User user);

    @Update("UPDATE s_user_info SET username=#{username},email=#{email} ,mobile=#{mobile} WHERE id =#{id}")
    void update(User user);

    @Delete("DELETE FROM s_user_info WHERE id =#{id}")
    void delete(Long id);



}
